package com.u17;

import java.util.PrimitiveIterator;

/**
 * @author u17
 * https://leetcode-cn.com/problems/reverse-integer/
 *
 */
public class Solution {

    public int reverse(int x) {


        int row = 0;

        int temp = 0;

        while (x != 0) {
            if (row < Integer.MIN_VALUE /10 || row > Integer.MAX_VALUE / 10) {
                return 0;
            }
            temp = x % 10;
            x = x / 10;
            row = row * 10 + temp;
        }

        return row;
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        int reverse = solution.reverse(1534236469);
        System.out.println(reverse);
        System.out.println(Integer.MIN_VALUE);
    }
}
